//
//  MyNoteBookView.m
//  MansApp
//
//  Created by lanou3g on 15/7/23.
//  Copyright (c) 2015年 ACH. All rights reserved.
//

#import "MyNoteBookView.h"
@implementation MyNoteBookView

- (instancetype)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    if (self) {
        
  
        self.myLabelWithField = [[UILabel alloc]initWithFrame:CGRectMake(kP6width(10), kP6Height(40), kP6width(50), kP6Height(40))];
        self.myLabelWithField.text = @"卷首:";
        self.myLabelWithField.font = [UIFont fontWithName:@"AmericanTypewriter-Bold" size:kP6Height(20) ];

        
        self.myTextField =  [[UITextField alloc]initWithFrame:CGRectMake(self.myLabelWithField.frame.origin.x + self.myLabelWithField.bounds.size.width + kP6width(10), self.myLabelWithField.frame.origin.y,kWidth - kP6Height(20) - self.myLabelWithField.frame.origin.x - self.myLabelWithField.bounds.size.width - kP6width(10), kP6Height(40))];
       self.myTextField.placeholder = @"无需操作...自动保存";
        self.myTextField.layer.borderWidth = 1;
        self.myTextField.layer.borderColor = [UIColor colorWithRed:181 / 255.0 green:181 / 255.0  blue:181 / 255.0 alpha:0.9].CGColor;
        self.myTextField.layer.cornerRadius = 5;
        self.myTextField.borderStyle = UITextBorderStyleRoundedRect;
        
        self.myTextView = [[UITextView alloc]initWithFrame:CGRectMake(kP6width(20),self.myTextField.frame.origin.y + self.myTextField.bounds.size.height + kP6Height(10), kWidth - kP6width(40), kP6Height(500))];
        self.myTextView.layer.borderWidth = 3;
//        self.myTextView.layer.borderColor = [UIColor colorWithRed:181 / 255.0 green:181 / 255.0  blue:181 / 255.0 alpha:0.9].CGColor;
        self.myTextView.layer.borderColor = [UIColor colorWithRed:47 / 255.0 green:79 / 255.0  blue:79 / 255.0 alpha:0.7].CGColor;
        self.myTextView.font = [UIFont fontWithName:@"Georgia-Italic" size:18];
        self.myTextView.layer.cornerRadius = 10;
        self.myTextView.backgroundColor = [UIColor clearColor];
        
        
        
        
        
        
        self.imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, kWidth, kHeight)];
        self.imageView.image = [UIImage imageNamed:@"318769-130G60R61724"];
        
        
        
        self.controlView = [[NoteControlMenuView alloc]initWithFrame:CGRectMake(0,self.myTextView.frame.origin.y + self.myTextView.bounds.size.height + kP6Height(10), kWidth, kP6Height(50))];
        
        self.fontControl = [[FontControl alloc]initWithFrame:CGRectMake(-300,self.controlView.frame.origin.y - kP6Height(30), kP6width(150), kP6Height(40))];
        self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(kP6width(200),3000,kP6width(150), kP6Height(100))];
        self.tableView.backgroundView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"2011082211521717"]];
        
        
        
        [self addSubview:self.imageView];
        [self addSubview:self.myTextView];
        [self addSubview:self.myTextField];
        [self addSubview: self.myLabelWithField];
        [self addSubview: self.controlView];
        [self addSubview: self.fontControl];
        [self addSubview:self.tableView];
        
        
   
     }
    return self;
}
- (void)myTextViewHeight:(CGFloat)height{
    if (height == -1) {
        return;
    }
    
    if (height == 0) {
            self.myTextView.frame  =  CGRectMake(kP6width(20),self.myTextField.frame.origin.y + self.myTextField.bounds.size.height + kP6Height(10), kWidth - kP6width(40), kP6Height(500));
    }
    else{
    self.myTextView.frame  =  CGRectMake(kP6width(20),self.myTextField.frame.origin.y + self.myTextField.bounds.size.height + kP6Height(10), kWidth - kP6width(40), kP6Height(550) - height);
    }
    
}


- (void)settingTableView:(id)target{
    
    self.tableView.delegate = target;
    self.tableView.dataSource = target;
    
}

-(BOOL)settingColor:(NSInteger)color{
    switch (color) {
        case 3:
        case 4:
        {
            self.myLabelWithField.textColor = [UIColor whiteColor];
            self.myTextView.layer.borderColor = [UIColor whiteColor].CGColor;
            self.myTextView.textColor = [UIColor whiteColor];
            [self.controlView.FontBigOrSmall setTintColor:[UIColor whiteColor]];
            [self.controlView.backgroundView setTintColor:[UIColor whiteColor]];
             return YES;
        }
            break;
         
        default:{
            self.myLabelWithField.textColor = [UIColor blackColor];
            self.myTextView.layer.borderColor = [UIColor colorWithRed:47 / 255.0 green:79 / 255.0  blue:79 / 255.0 alpha:0.7].CGColor;;
            self.myTextView.textColor = [UIColor blackColor];
            [self.controlView.FontBigOrSmall setTintColor:[UIColor blackColor]];
            [self.controlView.writeOrRead setTintColor:[UIColor blackColor]];
            [self.controlView.backgroundView setTintColor:[UIColor blackColor]];
            return NO;
        }
            break;
    }

}


@end
